<?php
include_once("include/include.php.inc");
html_header("Close ticket");
echo "<div class='box'>\n"; 
echo " <div class='boxtop'><div></div></div>\n"; 
echo "  <div class='boxcontent'>\n"; 
//include("connect_db.php");

/*   $backlink=getenv('HTTP_REFERER');*/

   if (empty($_POST['tic_no']) && empty($_GET['tic_no'])) {

   	   echo"<center>Please Enter a Ticket #</center>";
	  echo "  </div>\n"; 
echo " <div class='boxbottom'><div></div></div>\n"; 
echo "</div>\n"; 
echo "\n"; 
	   html_footer();
	   die();
	            
	
   }
   
   if (isset($_POST['tic_no'])) {
      $mtic = $_POST['tic_no'];
   } else {
      $mtic = $_GET['tic_no'];   
   }
  
      $result = "SELECT * FROM chd_tickets WHERE tic_no = '$mtic' AND tic_status = 'O' ";
      $action = mysql_query($result)
              or die("SELECT Error: ".mysql_error());
      $edit_row = mysql_fetch_array($action);
      if($edit_row['tic_no']=="") {
			
            echo "<center>The ticket number does not exists or it is already closed</center>";
echo "  </div>\n"; 
echo " <div class='boxbottom'><div></div></div>\n"; 
echo "</div>\n"; 
echo "\n"; 
			html_footer();
			die();
      }

/*               if (FALSE === ($action = mysql_query($result)))
              {
                  print mysql_error()."<br />";
                  print $result;
              }*/
 echo "<center>";
      			 print "<TABLE width=\"65%\" bgcolor=\"#336699\" BORDER=\"0\" bordercolor=\"#FFFFFF\"><tr>";
				 print "<th width=\"27%\" scope=\"col\"><div align=\"left\"><span class=\"style6\">Ticket No.</span></div></th>";
				 print "<td width=\"73%\" scope=\"col\" bgcolor=\"#FFFFFF\"><div align=\"left\"><span class=\"style8\">$mtic</span></div></td></tr>";
				 print "<tr><th scope=\"col\"><div align=\"left\"><span class=\"style6\">Problem</span></div></th>";
				 print "<td scope=\"col\" bgcolor=\"#FFFFFF\"><div align=\"left\"><span class=\"style8\">";
				 print $edit_row['tic_problem'];
				 print "</span></div></td></tr>";
				 print "</table>\n";
				 print "<br>";print "<br>";
               echo "</center>";
				 
echo "  </div>\n"; 
echo " <div class='boxbottom'><div></div></div>\n"; 
echo "</div>\n"; 
echo "\n"; 
				echo "<br>"; 
				 
				 
				 echo "<div class='box'>\n"; 
echo " <div class='boxtop'><div></div></div>\n"; 
echo "  <div class='boxcontent'>\n"; 
  print "<form action=\"pc_tic.php\" method=\"post\">";
                 print "<h2><center>Close Support Ticket</center></h2>";

                 print "<h4>Solution Provided: </h4>";
                 print "<textarea name=\"solution\" rows=\"3\" cols=\"72\"></TEXTAREA>";
                 print "<br>";print "<br>";
                 print "<input type=\"submit\" value=\" Update & Close Ticket \">";
                 print "<br><br>";
                 
   			if (isset($_POST['tic_no'])) {
                 print "<input type=\"hidden\" name=\"tic_no\" value='".$_POST['tic_no']."'>";
            } else {    
                 print "<input type=\"hidden\" name=\"tic_no\" value='".$_GET['tic_no']."'>";
            }     
				 print "</form>";

 
echo "  </div>\n"; 
echo " <div class='boxbottom'><div></div></div>\n"; 
echo "</div>\n"; 
echo "\n";

  
   html_footer();
?>